package com.reggie.controller.admin;

import com.reggie.result.R;
import com.reggie.service.ShopService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/shop")
@Api(tags = "店铺操作接口")
public class ShopController {

    @Autowired
    private ShopService shopService;

    /**
     * 店铺营业状态修改
     * @param status
     * @return
     */
    @PutMapping("/{status}")
    @ApiOperation("店铺营业状态修改")
    public R<String> setSHopStatus(@PathVariable Integer status){
        shopService.setShopStatus(status);
        return R.success();
    }


    //获取店铺的营业状态
    @GetMapping("/{status}")
    @ApiOperation("获取店铺营业状态")
    public R<Integer> getShopStatus(){
        Integer shopStatus =null;
        try {
            shopStatus = shopService.getStatus();
        }catch (Exception e){
            e.printStackTrace();
            shopStatus=1;
        }
        return R.success(shopStatus);

    }


}
